home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 (Walnut Creek) / Aminet - June 1993 [Walnut Creek].iso / usenet / sources / volume89 / graphics / mandelv2.7 < prev    next >
Internet Message Format  |  1989-06-21  |  52KB

  1. Path: xanth!ames!oliveb!sun!swap!page
  2. From: page%swap@Sun.COM (Bob Page)
  3. Newsgroups: comp.sources.amiga
  4. Subject: v89i158:  mandelvroom - mandelbrot explorer v2.0, Part07/09
  5. Message-ID: <111392@sun.Eng.Sun.COM>
  6. Date: 21 Jun 89 04:02:04 GMT
  7. Sender: news@sun.Eng.Sun.COM
  8. Lines: 2056
  9. Approved: page@sun.com
  10.  
  11. Submitted-by: kevin@uts.amdahl.com (Kevin Clague)
  12. Posting-number: Volume 89, Issue 158
  13. Archive-name: graphics/mandelv20.7
  14.  
  15. # This is a shell archive.
  16. # Remove anything above and including the cut line.
  17. # Then run the rest of the file through 'sh'.
  18. # Unpacked files will be owned by you and have default permissions.
  19. #----cut here-----cut here-----cut here-----cut here----#
  20. #!/bin/sh
  21. # shar: SHell ARchive
  22. # Run the following text through 'sh' to create:
  23. #    nav.c
  24. #    orbit.c
  25. #    orbitint.c
  26. #    packer.c
  27. #    palette.c
  28. # This is archive 7 of a 9-part kit.
  29. # This archive created: Tue Jun 20 20:45:31 1989
  30. echo "extracting nav.c"
  31. sed 's/^X//' << \SHAR_EOF > nav.c
  32. X/*
  33. X * MandelVroom 2.0
  34. X *
  35. X * (c) Copyright 1987,1989  Kevin L. Clague, San Jose, CA
  36. X *
  37. X * All rights reserved.
  38. X *
  39. X * Permission is hereby granted to distribute this program's source
  40. X * executable, and documentation for non-comercial purposes, so long as the
  41. X * copyright notices are not removed from the sources, executable or
  42. X * documentation.  This program may not be distributed for a profit without
  43. X * the express written consent of the author Kevin L. Clague.
  44. X *
  45. X * This program is not in the public domain.
  46. X *
  47. X * Fred Fish is expressly granted permission to distribute this program's
  48. X * source and executable as part of the "Fred Fish freely redistributable
  49. X * Amiga software library."
  50. X *
  51. X * Permission is expressly granted for this program and it's source to be
  52. X * distributed as part of the Amicus Amiga software disks, and the
  53. X * First Amiga User Group's Hot Mix disks.
  54. X *
  55. X * contents: this file contains the functions to handle MandelVroom's
  56. X * Zoom box which is used for navigation around in the complex plane.
  57. X */
  58. X
  59. X#include "mandp.h"
  60. X
  61. XSHORT BoxSizeX = 3, BoxSizeY = 3, DragSize = 3;
  62. X
  63. Xstatic SHORT HotSpotX, HotSpotY;
  64. X
  65. Xstruct Picture *ZoomedPict;
  66. X
  67. X#define MENUCODE(m,i,s) (SHIFTMENU(m)|SHIFTITEM(i)|SHIFTSUB(s))
  68. X
  69. X/*
  70. X * Picture (project) related commands
  71. X */
  72. X
  73. XZoomInCmd(Msg)
  74. X  struct IntuiMessage *Msg;
  75. X{
  76. X  struct Picture *Pict;
  77. X
  78. X  Pict = (struct Picture *) Msg->IDCMPWindow->UserData;
  79. X
  80. X  switch( Msg->Class ) {
  81. X
  82. X    case GADGETDOWN:
  83. X         ZoomedPict = Pict;
  84. X
  85. X    case MENUPICK:
  86. X         Pict->ZoomType = ZOOMIN;
  87. X         if ( ! (Pict->Flags & SCROLL_HAPPENED)) {
  88. X           CloseZoomBox(Pict);
  89. X           SetToPointer();
  90. X           State = ZOOMINSTATE;
  91. X         }
  92. X         break;
  93. X
  94. X    case MOUSEBUTTONS:
  95. X         if (Msg->Code == SELECTDOWN) {
  96. X           if (ZoomedPict->pNode.ln_Type == Pict->pNode.ln_Type) {
  97. X             StartZoomBox(ZoomedPict, Pict);
  98. X             ResizeZoomCmd(Msg); /* Pass control off to resize routine */
  99. X           }
  100. X         }
  101. X         break;
  102. X  }
  103. X}
  104. X
  105. X/*
  106. X * StartZoomOut
  107. X */
  108. XZoomOutCmd( Msg )
  109. X  struct IntuiMessage *Msg;
  110. X{
  111. X  register struct Picture *Pict;
  112. X
  113. X  if (Msg->Class == MENUPICK) {
  114. X    Pict = CurPict;
  115. X  } else {
  116. X    Pict = (struct Picture *) Msg->IDCMPWindow->UserData;
  117. X  }
  118. X  Pict->ZoomType = ZOOMOUT;
  119. X
  120. X  AddHead( &Pict->zList, &Pict->zNode );
  121. X
  122. X  Pict->Flags   |= ZOOM_BOX_OPEN;
  123. X  Pict->DrawPict = Pict;
  124. X
  125. X  Pict->NavLeft  = Pict->LeftMarg;
  126. X  Pict->NavRight = Pict->CountX + Pict->NavLeft - 1;
  127. X  Pict->NavTop   = Pict->TopMarg;
  128. X  Pict->NavBot   = Pict->CountY + Pict->NavTop - 1;
  129. X
  130. X  ZoomOnOff( Pict );
  131. X}
  132. X
  133. XResizeZoomCmd(Msg)
  134. X  struct IntuiMessage *Msg;
  135. X{
  136. X  struct Window  *Window;
  137. X  struct Picture *Pict;
  138. X
  139. X  Window = Msg->IDCMPWindow;
  140. X  Pict   = (struct Picture *) Window->UserData;
  141. X
  142. X  switch( Msg->Class ) {
  143. X
  144. X    case MOUSEBUTTONS:
  145. X         switch (Msg->Code) {
  146. X
  147. X           case SELECTDOWN:
  148. X
  149. X                if (State != ZOOMINSTATE)
  150. X                  ZoomExtras(ZoomedPict);
  151. X                AllocLensTemp( ZoomedPict );
  152. X                ModifyIDCMP(Window, Window->IDCMPFlags |  MOUSEMOVE);
  153. X                State = RESIZEZOOMSTATE;
  154. X                break;
  155. X
  156. X           case SELECTUP:
  157. X                ModifyIDCMP(Window, Window->IDCMPFlags & ~MOUSEMOVE);
  158. X                FreeLensTemp();
  159. X                FinishResize(ZoomedPict);
  160. X                State = IDLESTATE;
  161. X                break;
  162. X         }
  163. X         break;
  164. X
  165. X    case MOUSEMOVE:
  166. X         StretchZoomBox( ZoomedPict );
  167. X         break;
  168. X  }
  169. X}
  170. X
  171. XZoomDragCmd(Msg)
  172. X  struct IntuiMessage *Msg;
  173. X{
  174. X  struct Window *Window;
  175. X  struct Picture *Pict;
  176. X
  177. X  Window = Msg->IDCMPWindow;
  178. X  Pict = (struct Picture *) Window->UserData;
  179. X
  180. X  switch( Msg->Class ) {
  181. X
  182. X    case MOUSEBUTTONS:
  183. X         ZoomExtras( ZoomedPict );            /* draw/undraw the extras */
  184. X         switch( Msg->Code ) {
  185. X
  186. X           case SELECTDOWN:                   /* start drag */
  187. X                AllocLensTemp( ZoomedPict );
  188. X                ModifyIDCMP(Window, Window->IDCMPFlags | MOUSEMOVE);
  189. X                State = ZOOMDRAGSTATE;
  190. X                break;
  191. X
  192. X           case SELECTUP:                     /* stop slide */
  193. X                FreeLensTemp();
  194. X                ModifyIDCMP(Window, Window->IDCMPFlags & ~MOUSEMOVE);
  195. X                State = IDLESTATE;
  196. X                break;
  197. X         }
  198. X         break;
  199. X
  200. X    case MOUSEMOVE:
  201. X         DragZoomBox( ZoomedPict );
  202. X         Lens( ZoomedPict );
  203. X         break;
  204. X  }
  205. X}
  206. X
  207. XPropResizeCmd(Msg)
  208. X  struct IntuiMessage *Msg;
  209. X{
  210. X  struct Window *Window;
  211. X  struct Picture *Pict;
  212. X
  213. X  Window = Msg->IDCMPWindow;
  214. X  Pict = (struct Picture *) Window->UserData;
  215. X
  216. X  switch( Msg->Class ) {
  217. X
  218. X    case MOUSEBUTTONS:
  219. X         ZoomExtras( ZoomedPict );            /* draw/undraw the extras */
  220. X         switch( Msg->Code ) {
  221. X
  222. X           case SELECTDOWN:                   /* start resize */
  223. X                AllocLensTemp( ZoomedPict );
  224. X                StartPropStrech( ZoomedPict );
  225. X                ModifyIDCMP(Window, Window->IDCMPFlags | MOUSEMOVE);
  226. X                State = PROPRESIZESTATE;
  227. X                break;
  228. X
  229. X           case SELECTUP:                     /* stop resize */
  230. X                FreeLensTemp();
  231. X                ModifyIDCMP(Window, Window->IDCMPFlags & ~MOUSEMOVE);
  232. X                State = IDLESTATE;
  233. X                break;
  234. X         }
  235. X         break;
  236. X
  237. X    case MOUSEMOVE:
  238. X         PropStretchBox( ZoomedPict );
  239. X         Lens( ZoomedPict );
  240. X         break;
  241. X  }
  242. X}
  243. X
  244. XSetJuliaCmd(Msg)
  245. X  struct IntuiMessage *Msg;
  246. X{
  247. X  switch( Msg->Class ) {
  248. X
  249. X    case MENUPICK:
  250. X         SetToPointer();
  251. X         ZoomedPict = CurPict;
  252. X         State = SETJULIASTATE;
  253. X         break;
  254. X
  255. X    case GADGETDOWN:
  256. X         SetToPointer();
  257. X         ZoomedPict = (struct Picture *) Msg->IDCMPWindow->UserData;
  258. X         State = SETJULIASTATE;
  259. X         break;
  260. X
  261. X    case MOUSEBUTTONS:
  262. X         if (Msg->Code == SELECTDOWN) {
  263. X
  264. X           SetJuliaPt(ZoomedPict,
  265. X                      (struct Picture *) Msg->IDCMPWindow->UserData);
  266. X           State = IDLESTATE;
  267. X         }
  268. X         break;
  269. X  }
  270. X}
  271. X
  272. XQueryHeightCmd(Msg)
  273. X  struct IntuiMessage *Msg;
  274. X{
  275. X  struct Window *Window;
  276. X  struct Picture *Pict;
  277. X
  278. X  Window = Msg->IDCMPWindow;
  279. X  Pict = (struct Picture *) Window->UserData;
  280. X
  281. X  if (Pict->Flags & SCROLL_HAPPENED)
  282. X    return;
  283. X
  284. X  switch( Msg->Class ) {
  285. X
  286. X    case MOUSEBUTTONS:
  287. X         switch( Msg->Code ) {
  288. X                                              /* start query */
  289. X           case SELECTDOWN:
  290. X                if (Pict->Counts && !(Pict->Flags & NO_RAM_GENERATE)) {
  291. X                  ShowContour( MouseX, MouseY, 1 );
  292. X                  ModifyIDCMP(Window, Window->IDCMPFlags | MOUSEMOVE);
  293. X                  State = QUERYHEIGHTSTATE;
  294. X                }
  295. X                break;
  296. X
  297. X           case SELECTUP:                     /* stop query */
  298. X                ModifyIDCMP(Window, Window->IDCMPFlags & ~MOUSEMOVE);
  299. X                State = IDLESTATE;
  300. X                break;
  301. X         }
  302. X         break;
  303. X
  304. X    case MOUSEMOVE:
  305. X         ShowContour( MouseX, MouseY, 0);
  306. X         break;
  307. X  }
  308. X}
  309. X
  310. Xstatic int OldHeight; /* used to detect title change */
  311. X
  312. XShowContour(MouseX,MouseY,Flag)
  313. X  register int MouseX,MouseY;
  314. X  register int Flag;
  315. X{
  316. X  register struct Picture *Pict;
  317. X
  318. X  static char ScreenTitle[80];
  319. X
  320. X  int Height;
  321. X  float r, i;
  322. X
  323. X  Pict = (struct Picture *) CurWind->UserData;
  324. X
  325. X  if (Pict == NULL)
  326. X    return;
  327. X
  328. X  if (MouseX >= Pict->LeftMarg &&
  329. X      MouseY >= Pict->TopMarg  &&
  330. X      MouseX <  CurWind->Width  - Pict->RightMarg &&
  331. X      MouseY <  CurWind->Height - Pict->BotMarg) {
  332. X
  333. X    Height = HeightPicked(Pict,MouseX,MouseY);
  334. X    r = Pict->RealLow + (MouseX - Pict->LeftMarg) * Pict->RealGap;
  335. X    i = Pict->ImagLow + (MouseY - Pict->TopMarg) * Pict->ImagGap;
  336. X
  337. X    sprintf(ScreenTitle,"Height %3d r %f i %f",
  338. X                         Height, r, i);
  339. X
  340. X    SetWindowTitles( CurWind, (long) -1, ScreenTitle );
  341. X  }
  342. X}
  343. X
  344. X/*
  345. X * Start Zoom box
  346. X */
  347. XStartZoomBox( NavPict, DrawPict )
  348. X  register struct Picture *NavPict;
  349. X  register struct Picture *DrawPict;
  350. X{
  351. X  register struct Window  *Window = DrawPict->Window;
  352. X
  353. X  CloseZoomBox( NavPict);
  354. X
  355. X  AddHead( &DrawPict->zList, &NavPict->zNode );
  356. X
  357. X  NavPict->Flags    |= ZOOM_BOX_OPEN;
  358. X  NavPict->DrawPict  = DrawPict;
  359. X
  360. X  /* Draw first box */
  361. X  NavPict->NavTop   = NavPict->NavBot   = MouseY;
  362. X  NavPict->NavLeft  = NavPict->NavRight = MouseX;
  363. X
  364. X  ZoomBox( NavPict );
  365. X}
  366. X
  367. XStretchZoomBox( Pict )
  368. X  register struct Picture *Pict;
  369. X{
  370. X  register struct Picture  *DrawPict = Pict->DrawPict;
  371. X  register LONG Left = DrawPict->CountX + DrawPict->LeftMarg;
  372. X  register LONG Top  = DrawPict->CountY + DrawPict->TopMarg;
  373. X
  374. X  ZoomBox( Pict );
  375. X
  376. X  if ( MouseX < Pict->NavLeft )
  377. X    MouseX = Pict->NavLeft;
  378. X
  379. X  if ( MouseY < Pict->NavTop )
  380. X    MouseY = Pict->NavTop;
  381. X
  382. X  if ( MouseX > Left )
  383. X    MouseX = Left-1;
  384. X
  385. X  if ( MouseY > Top )
  386. X    MouseY = Top-1;
  387. X
  388. X  Pict->NavBot   = MouseY;
  389. X  Pict->NavRight = MouseX;
  390. X
  391. X  Lens( Pict );
  392. X
  393. X  ZoomBox( Pict );
  394. X}
  395. X
  396. Xstatic double ZoomAspectRatio;
  397. X
  398. XStartPropStrech( Pict )
  399. X  register struct Picture *Pict;
  400. X{
  401. X  ZoomAspectRatio = (double) (Pict->NavRight - Pict->NavLeft) /
  402. X                   (double) (Pict->NavBot - Pict->NavTop);
  403. X}
  404. X
  405. XPropStretchBox( Pict )
  406. X  register struct Picture *Pict;
  407. X{
  408. X  register LONG Left = Pict->LeftMarg;
  409. X  register LONG Top  = Pict->DrawPict->CountY + Pict->TopMarg;
  410. X
  411. X  register LONG CenterX = Pict->NavRight - Pict->NavLeft;
  412. X  register LONG CenterY = Pict->NavBot - Pict->NavTop;
  413. X
  414. X  LONG NewLeft,NewRight,NewTop;
  415. X
  416. X  ZoomBox( Pict );
  417. X
  418. X  CenterX = Pict->NavLeft + CenterX / 2;
  419. X  CenterY = Pict->NavTop + CenterY / 2;
  420. X
  421. X  if ( MouseX > CenterX-4 )  MouseX = CenterX-4;
  422. X  if ( MouseY < CenterY+4 )  MouseY = CenterY+4;
  423. X
  424. X#if 0
  425. X  if ( MouseX < Left ) MouseX = Left;  /* don't let it flip */
  426. X  if ( MouseY > Top )  MouseY = Top;
  427. X#endif
  428. X
  429. X  Top = MouseY - CenterY;
  430. X  Left = (LONG) ((float) Top * ZoomAspectRatio);
  431. X
  432. X  NewLeft = CenterX - Left;
  433. X  NewRight = CenterX + Left;
  434. X  NewTop = CenterY - Top;
  435. X
  436. X  if (NewLeft  >= Pict->LeftMarg &&
  437. X      NewRight <  Pict->DrawPict->Window->Width - Pict->RightMarg &&
  438. X      NewTop   >= Pict->TopMarg ) {
  439. X
  440. X    Pict->NavBot = MouseY;
  441. X    Pict->NavTop = NewTop;
  442. X    Pict->NavLeft  = NewLeft;
  443. X    Pict->NavRight = NewRight;
  444. X  }
  445. X
  446. X  Lens( Pict );
  447. X
  448. X  ZoomBox( Pict );
  449. X}
  450. X
  451. X#define MINXBOX (8 << XScale)
  452. X#define MINYBOX (7 << YScale)
  453. X
  454. XFinishResize( Pict )
  455. X  struct Picture *Pict;
  456. X{
  457. X  register int t;
  458. X
  459. X  if (Pict->NavBot < Pict->NavTop) {
  460. X    t            = Pict->NavBot;
  461. X    Pict->NavBot = Pict->NavTop;
  462. X    Pict->NavTop = t;
  463. X  }
  464. X  if (Pict->NavRight < Pict->NavLeft) {
  465. X    t              = Pict->NavRight;
  466. X    Pict->NavRight = Pict->NavLeft;
  467. X    Pict->NavLeft  = t;
  468. X  }
  469. X
  470. X  ZoomBox( Pict );
  471. X
  472. X  if (Pict->NavRight - Pict->NavLeft < MINXBOX )
  473. X    Pict->NavRight = Pict->NavLeft + MINXBOX;
  474. X
  475. X  if (Pict->NavBot - Pict->NavTop < MINYBOX )
  476. X    Pict->NavBot = Pict->NavTop + MINYBOX;
  477. X
  478. X  ZoomOnOff( Pict );
  479. X}
  480. X
  481. XDragZoomBox( Pict )
  482. X  register struct Picture *Pict;
  483. X{
  484. X  register struct Picture *DrawPict = Pict->DrawPict;
  485. X  register LONG Width, Height;
  486. X
  487. X  ZoomBox( Pict );
  488. X
  489. X  Width  = Pict->NavRight - Pict->NavLeft - HotSpotX;
  490. X  Height = Pict->NavBot -   Pict->NavTop - HotSpotY;
  491. X
  492. X  if ( MouseY < 1 )
  493. X    MouseY = 1;
  494. X
  495. X  if ( MouseX - HotSpotX < DrawPict->LeftMarg )
  496. X    MouseX = DrawPict->LeftMarg + HotSpotX;
  497. X
  498. X  if ( MouseY - HotSpotY < DrawPict->TopMarg )
  499. X    MouseY = DrawPict->TopMarg + HotSpotY;
  500. X
  501. X  if ( MouseX + Width >= DrawPict->CountX + DrawPict->LeftMarg )
  502. X    MouseX = DrawPict->CountX + DrawPict->LeftMarg - Width;
  503. X
  504. X  if ( MouseY + Height >= DrawPict->CountY + DrawPict->TopMarg )
  505. X    MouseY = DrawPict->CountY + DrawPict->TopMarg - Height;
  506. X
  507. X  Pict->NavLeft  = MouseX - HotSpotX;
  508. X  Pict->NavTop   = MouseY - HotSpotY;
  509. X
  510. X  Pict->NavRight = MouseX + Width;
  511. X  Pict->NavBot   = MouseY + Height;
  512. X
  513. X  Lens( Pict );
  514. X
  515. X  ZoomBox( Pict );
  516. X}
  517. X
  518. XCloseZoomBox( Pict )
  519. X  struct Picture *Pict;
  520. X{
  521. X  if (Pict) {
  522. X    if (Pict->Flags & ZOOM_BOX_OPEN) {
  523. X      ZoomOnOff( Pict );
  524. X      Remove( &Pict->zNode );
  525. X      Pict->Flags &= ~ZOOM_BOX_OPEN;
  526. X    }
  527. X    Pict->DrawPict = NULL;
  528. X  }
  529. X}
  530. X
  531. XClearZoomBox(Pict)
  532. X  struct Picture *Pict;
  533. X{
  534. X  CloseZoomBox( Pict );
  535. X  ZoomedPict = NULL;
  536. X}
  537. X
  538. XZoomBox( Pict )
  539. X  register struct Picture *Pict;
  540. X{
  541. X  if ( Pict && Pict->DrawPict && Pict->DrawPict->Window) {
  542. X
  543. X    ObtainSemaphore( &Pict->WindowSemi );
  544. X    DrawBox( Pict->DrawPict->Window,
  545. X             Pict->NavLeft,  Pict->NavTop,
  546. X             Pict->NavRight, Pict->NavBot );
  547. X    ReleaseSemaphore( &Pict->WindowSemi );
  548. X  }
  549. X}
  550. X
  551. XZoomExtras( Pict )
  552. X  register struct Picture *Pict;
  553. X{
  554. X  if ( Pict && Pict->DrawPict && Pict->DrawPict->Window) {
  555. X
  556. X
  557. X    ObtainSemaphore( &Pict->WindowSemi );
  558. X    DrawExtras( Pict->DrawPict->Window,
  559. X                Pict->NavLeft,  Pict->NavTop,
  560. X                Pict->NavRight, Pict->NavBot );
  561. X    ReleaseSemaphore( &Pict->WindowSemi );
  562. X  }
  563. X}
  564. X
  565. XZoomOnOff( Pict )
  566. X  register struct Picture *Pict;
  567. X{
  568. X  ZoomBox( Pict );
  569. X  ZoomExtras( Pict );
  570. X}
  571. X
  572. XDrawBox( Window, PLeft, PTop, PRight, PBottom)
  573. X  struct Window *Window;
  574. X  SHORT PTop, PLeft, PBottom, PRight;
  575. X{
  576. X  register struct RastPort *Rp;
  577. X  register LONG Top, Left, Right, Bottom;
  578. X
  579. X  Rp = Window->RPort;
  580. X
  581. X  Top = PTop;
  582. X  Left = PLeft;
  583. X  Right = PRight;
  584. X  Bottom = PBottom;
  585. X
  586. X  SetDrMd(Rp, COMPLEMENT);
  587. X  /*
  588. X   * Draw the new box
  589. X   */
  590. X  Move(Rp, Left,  Top   );
  591. X  Draw(Rp, Right, Top   );
  592. X  Draw(Rp, Right, Bottom);
  593. X  Draw(Rp, Left,  Bottom);
  594. X  Draw(Rp, Left,  Top+1 );
  595. X
  596. X  SetDrMd(Rp, JAM1);
  597. X} /* DrawBox */
  598. X
  599. XDrawExtras( Window, Left, Top, Right, Bottom)
  600. X  struct Window *Window;
  601. X  SHORT Top, Left, Bottom, Right;
  602. X{
  603. X  register struct RastPort *Rp = Window->RPort;
  604. X  register LONG ResizeTop  = Bottom - ( BoxSizeY << YScale );
  605. X  register LONG ResizeLeft = Right  - ( BoxSizeX << XScale );
  606. X  register LONG BotDrag = Top + ( DragSize << YScale );
  607. X
  608. X  SetDrMd(Rp, COMPLEMENT);
  609. X  /*
  610. X   * Draw Normal Resize gadget
  611. X   */
  612. X  Move(Rp, (long) Right - 1,  ResizeTop );
  613. X  Draw(Rp, ResizeLeft, ResizeTop );
  614. X  Draw(Rp, ResizeLeft, (long) Bottom - 1);
  615. X
  616. X  /*
  617. X   * Draw Proportional Resize gadget
  618. X   */
  619. X  ResizeLeft = Left + ( BoxSizeX << XScale );
  620. X
  621. X  Move(Rp, (long) Left + 1,  ResizeTop );
  622. X  Draw(Rp, ResizeLeft, ResizeTop );
  623. X  Draw(Rp, ResizeLeft, (long) Bottom - 1);
  624. X
  625. X  /*
  626. X   * Drag bar bar / close gadget separator
  627. X   */
  628. X  Move(Rp, (long) Left  + 1,  BotDrag );
  629. X  Draw(Rp, (long) Right - 1,  BotDrag );
  630. X
  631. X  Move(Rp, (long) Left + (4 << XScale), (long) Top + 1);
  632. X  Draw(Rp, (long) Left + (4 << XScale), BotDrag - 1 );
  633. X
  634. X  SetDrMd(Rp, JAM1);
  635. X} /* DrawExtras */
  636. X
  637. X/*
  638. X * ZoomIn
  639. X */
  640. XZoomIn( NavPict )
  641. X  register struct Picture *NavPict;
  642. X{
  643. X  register struct Picture *DrawPict = NavPict->DrawPict;
  644. X  double left,  top;
  645. X  double right, bot;
  646. X
  647. X  double AspectRatio();
  648. X
  649. X  double Gap;
  650. X
  651. X  if (DrawPict) {
  652. X
  653. X    left  = (double) (NavPict->NavLeft  - DrawPict->LeftMarg);
  654. X    top   = (double) (NavPict->NavTop   - DrawPict->TopMarg);
  655. X    right = (double) (NavPict->NavRight - DrawPict->LeftMarg);
  656. X    bot   = (double) (NavPict->NavBot   - DrawPict->TopMarg);
  657. X
  658. X    switch( NavPict->ZoomType ) {
  659. X      case  ZOOMIN:
  660. X
  661. X            NavPict->RealHigh = DrawPict->RealLow + DrawPict->RealGap*right;
  662. X            NavPict->ImagHigh = DrawPict->ImagLow + DrawPict->ImagGap*bot;
  663. X            NavPict->RealLow  = DrawPict->RealLow + DrawPict->RealGap*left;
  664. X            NavPict->ImagLow  = DrawPict->ImagLow + DrawPict->ImagGap*top;
  665. X
  666. X            NavPict->Real     = DrawPict->Real;
  667. X            NavPict->Imag     = DrawPict->Imag;
  668. X            break;
  669. X
  670. X      case  ZOOMOUT:
  671. X
  672. X            Gap = (DrawPict->ImagHigh - DrawPict->ImagLow) / (bot - top);
  673. X
  674. X            NavPict->ImagLow  -= top * Gap;
  675. X            NavPict->ImagHigh = NavPict->ImagLow +
  676. X                                (double) NavPict->CountY*Gap;
  677. X
  678. X            NavPict->ImagGap = Gap;
  679. X            NavPict->RealGap = Gap *= AspectRatio(NavPict);
  680. X
  681. X            NavPict->RealLow  -= left * Gap;
  682. X            NavPict->RealHigh = NavPict->RealLow +
  683. X                                (double) NavPict->CountX*Gap;
  684. X    }
  685. X
  686. X    CloseZoomBox( NavPict );
  687. X  }
  688. X  CalculateGaps( NavPict );
  689. X} /* ZoomIn */
  690. X
  691. X/*
  692. X * Calculate Gaps
  693. X */
  694. XCalculateGaps( Pict )
  695. X  register struct Picture *Pict;
  696. X{
  697. X  double AspectRatio();
  698. X
  699. X  Pict->ImagGap = (Pict->ImagHigh - Pict->ImagLow) / (double) Pict->CountY;
  700. X  Pict->RealGap = Pict->ImagGap * AspectRatio( Pict );
  701. X}
  702. X
  703. X/*
  704. X * Apsect Ratio - IEEE
  705. X */
  706. Xdouble
  707. XAspectRatio( Pict )
  708. X  register struct Picture *Pict;
  709. X{
  710. X  double aspectratio;
  711. X
  712. X  if (Pict->ViewModes & HIRES)
  713. X    if (Pict->ViewModes & INTERLACE)
  714. X      aspectratio = 0.88;
  715. X    else
  716. X      aspectratio = 0.44;
  717. X  else
  718. X    if (Pict->ViewModes & INTERLACE)
  719. X      aspectratio = 1.76;
  720. X    else
  721. X      aspectratio = 0.88;
  722. X
  723. X  return( aspectratio );
  724. X}
  725. X
  726. X/*
  727. X * Simulate Zoom box gadgets
  728. X */
  729. Xint
  730. XCheckPictZoomBox( NavPict )
  731. X  register struct Picture  *NavPict;
  732. X{
  733. X  register struct Picture *DrawPict = NavPict->DrawPict;
  734. X  register struct Window  *Window = DrawPict->Window;
  735. X
  736. X  register LONG BoxX;
  737. X
  738. X  BoxX = BoxSizeX << XScale;
  739. X
  740. X  /* is it in the window box? */
  741. X  if (MouseX >= NavPict->NavLeft && MouseX <= NavPict->NavRight &&
  742. X      MouseY >= NavPict->NavTop  && MouseY <= NavPict->NavBot) {
  743. X
  744. X    /* is it in the top part? */
  745. X    if (MouseY <= NavPict->NavTop + (DragSize << YScale) ) {
  746. X
  747. X      /* is it the drag bar? */
  748. X      if (MouseX > NavPict->NavLeft + BoxX ) {
  749. X
  750. X        HotSpotX = MouseX - NavPict->NavLeft;
  751. X        HotSpotY = MouseY - NavPict->NavTop;
  752. X        return(ZOOMDRAGHIT);
  753. X
  754. X      } else {                     /* We got the close gadget */
  755. X
  756. X        return(ZOOMCLOSEHIT);
  757. X      }
  758. X    } else {
  759. X
  760. X      /* is it the Resize Gadget? */
  761. X      if (MouseY >= NavPict->NavBot - ((BoxSizeY + 1) << YScale) ) {
  762. X
  763. X        if ( MouseX > NavPict->NavRight - BoxX ) {
  764. X
  765. X          return(ZOOMRESIZEHIT);
  766. X
  767. X        } else
  768. X        if ( MouseX <= NavPict->NavLeft + BoxX ) {
  769. X
  770. X          return(PROPRESIZEHIT);
  771. X        }
  772. X      }
  773. X    }
  774. X  }
  775. X  return(NOTHINGHIT);
  776. X}
  777. X
  778. XSetJuliaPt( ZoomedPict, Pict )
  779. X  register struct Picture *ZoomedPict, *Pict;
  780. X{
  781. X  register LONG x,y;
  782. X
  783. X  if (ZoomedPict && Pict &&
  784. X      ZoomedPict->pNode.ln_Type != Pict->pNode.ln_Type) {
  785. X
  786. X    x = MouseX - Pict->LeftMarg;
  787. X    y = MouseY - Pict->TopMarg;
  788. X
  789. X    ZoomedPict->Real = Pict->RealLow + x * Pict->RealGap;
  790. X    ZoomedPict->Imag = Pict->ImagLow + y * Pict->ImagGap;
  791. X  }
  792. X}
  793. SHAR_EOF
  794. echo "extracting orbit.c"
  795. sed 's/^X//' << \SHAR_EOF > orbit.c
  796. X/*
  797. X * MandelVroom 2.0
  798. X *
  799. X * (c) Copyright 1987,1989  Kevin L. Clague, San Jose, CA
  800. X *
  801. X * All rights reserved.
  802. X *
  803. X * Permission is hereby granted to distribute this program's source
  804. X * executable, and documentation for non-comercial purposes, so long as the
  805. X * copyright notices are not removed from the sources, executable or
  806. X * documentation.  This program may not be distributed for a profit without
  807. X * the express written consent of the author Kevin L. Clague.
  808. X *
  809. X * This program is not in the public domain.
  810. X *
  811. X * Fred Fish is expressly granted permission to distribute this program's
  812. X * source and executable as part of the "Fred Fish freely redistributable
  813. X * Amiga software library."
  814. X *
  815. X * Permission is expressly granted for this program and it's source to be
  816. X * distributed as part of the Amicus Amiga software disks, and the
  817. X * First Amiga User Group's Hot Mix disks.
  818. X *
  819. X * contents: this file contains the functions that open, maintain and
  820. X * close the orbit window.
  821. X */
  822. X
  823. X#define PARSEGOOD 0
  824. X#define PARSEBAD  1
  825. X
  826. X#include "mandp.h"
  827. X#include "parms.h"
  828. X
  829. XSHORT MaxOrbit = 32;
  830. XUBYTE OrbitMode = 1;
  831. X
  832. XUBYTE OrbitOpen;
  833. X
  834. Xstruct NewWindow NewOrbit = {
  835. X   100, 12,                  /* start position           */
  836. X   130,80,                   /* width, height            */
  837. X
  838. X   (UBYTE) 0, (UBYTE) NORMALPEN,
  839. X   NULL,                     /* IDCMP flags */
  840. X   /* OrbitWind flags */
  841. X   WINDOWCLOSE | WINDOWDEPTH | WINDOWSIZING | WINDOWDRAG | ACTIVATE |
  842. X   NOCAREREFRESH | SMART_REFRESH,
  843. X   (struct Gadget *) NULL,   /* first gadget             */
  844. X   (struct Image *) NULL,    /* user checkmark           */
  845. X   (UBYTE *) "Orbit",        /* Title                    */
  846. X   (struct Screen *) NULL,   /* pointer to screen        */
  847. X   (struct BitMap *) NULL,   /* pointer to superbitmap   */
  848. X   20,20,-1,-1,              /* sizing                   */
  849. X   CUSTOMSCREEN              /* type of screen           */
  850. X};
  851. X
  852. Xstruct Window *OrbitWind;
  853. X
  854. XConfOrbMode( subnum )
  855. X  int subnum;
  856. X{
  857. X  OrbitMode = subnum;
  858. X}
  859. X
  860. XOrbitCmd( msg )
  861. X  register struct IntuiMessage *msg;
  862. X{
  863. X  static struct Picture *OrbitPict;
  864. X  register struct Window *Window;
  865. X
  866. X  switch( msg->Class ) {
  867. X    case MENUPICK:
  868. X    case GADGETDOWN:
  869. X         OpenOrbitWind();
  870. X         break;
  871. X
  872. X    case MOUSEBUTTONS:
  873. X
  874. X         Window = (struct Window *) msg->IDCMPWindow;
  875. X
  876. X         switch (msg->Code) {
  877. X           case SELECTDOWN:
  878. X
  879. X                OrbitPict = (struct Picture *) Window->UserData;
  880. X
  881. X                if (OrbitPict != NULL &&
  882. X                  !(OrbitPict->Flags & SCROLL_HAPPENED)) {
  883. X
  884. X                  ModifyIDCMP( Window,
  885. X                               (long) Window->IDCMPFlags | MOUSEMOVE );
  886. X                  DrawOrbit(OrbitPict);
  887. X                }
  888. X                break;
  889. X
  890. X           case SELECTUP:
  891. X
  892. X                if (OrbitPict != NULL) {
  893. X
  894. X                  ModifyIDCMP( Window,
  895. X                               (long) Window->IDCMPFlags & ~MOUSEMOVE );
  896. X                  OrbitPict = NULL;
  897. X                }
  898. X                break;
  899. X         }
  900. X         break;
  901. X
  902. X    case MOUSEMOVE:
  903. X
  904. X         if (OrbitPict != NULL) {
  905. X           DrawOrbit( OrbitPict );
  906. X         }
  907. X         break;
  908. X  }
  909. X}
  910. X
  911. XDrawOrbit( Pict )
  912. X  struct Picture *Pict;
  913. X{
  914. X  switch( OrbitMode ) {
  915. X    case 1:   /* ffp       */
  916. X         {    /* 32 bit IEEE float variables */
  917. X
  918. X           float CReal_float, CImag_float, ZReal_float, ZImag_float;
  919. X
  920. X           if (OpenFFPLibs() != 0)
  921. X             return;
  922. X
  923. X           /* convert 64 bit IEEE variables into 32 bit IEEE variables */
  924. X
  925. X           CReal_float =
  926. X             Pict->RealLow + (MouseX-Pict->LeftMarg) * Pict->RealGap;
  927. X           CImag_float =
  928. X             Pict->ImagLow + (MouseY-Pict->TopMarg) * Pict->ImagGap;
  929. X
  930. X           ZReal_float   = Pict->Real;
  931. X           ZImag_float   = Pict->Imag;
  932. X
  933. X           /*
  934. X            * calculate pointers and convert them to pointers to ULONG
  935. X            * so that when we indirect off of these and pass the results
  936. X            * as parameters they are not promoted to doubles.
  937. X            */
  938. X
  939. X           DrawOrbitFFP( Pict,
  940. X                         *((ULONG *) &CReal_float),
  941. X                         *((ULONG *) &CImag_float),
  942. X                         *((ULONG *) &ZReal_float),
  943. X                         *((ULONG *) &ZImag_float));
  944. X         }
  945. X         break;
  946. X
  947. X    case 0:   /* int 16/32 */
  948. X         DrawOrbitInt( Pict );
  949. X         break;
  950. X
  951. X    case 2:   /* ieee      */
  952. X         DrawOrbitIEEE( Pict );
  953. X         break;
  954. X  }
  955. X}
  956. X
  957. Xstruct Gadget *
  958. XMakeOrbitGads()
  959. X{
  960. X  register struct Gadget *Firstgadget;
  961. X  register struct IntuiText  *Intui;
  962. X
  963. X  struct IntuiText *ShadowIntui();
  964. X  struct Border *Border, *MakeShadow();
  965. X
  966. X  Firstgadget = MakeBool(-15,TOPMARG, 12,12, 0,ORBTTYPE<<WINDTYPEBITS,NULL);
  967. X
  968. X  if (Firstgadget == NULL) {
  969. X    return( Firstgadget );
  970. X  }
  971. X
  972. X  Firstgadget->Flags      |= GRELRIGHT;
  973. X  Firstgadget->Activation |= RIGHTBORDER;
  974. X
  975. X  Intui = ShadowIntui( "O", 3, 3);
  976. X
  977. X  if (Intui == NULL) {
  978. X    FreeGadgets( Firstgadget );
  979. X    return( NULL );
  980. X  }
  981. X
  982. X  Firstgadget->GadgetText = Intui;
  983. X
  984. X#define NUMPATCHCORNERS 5
  985. X
  986. X  Border = MakeShadow( NORMALPEN, NUMPATCHCORNERS );
  987. X
  988. X  if ( Border ) {
  989. X    InitPatch( Border );
  990. X
  991. X    Border->NextBorder = (struct Border *) Firstgadget->GadgetRender;
  992. X    Firstgadget->GadgetRender = (APTR) Border;
  993. X  }
  994. X
  995. X  return( Firstgadget );
  996. X}
  997. X
  998. Xstatic struct Gadget *OrbitGadgets;
  999. Xstruct Gadget *OrbitResize;
  1000. X
  1001. X/*
  1002. X * Open the Orbit window
  1003. X */
  1004. XOpenOrbitWind()
  1005. X{
  1006. X  extern struct Window *OpenMyWind();
  1007. X
  1008. X  register struct Window    *Window;
  1009. X  register struct NewWindow *NewWind;
  1010. X
  1011. X  struct Gadget *gadgets;
  1012. X
  1013. X  if ( OrbitWind == NULL ) {
  1014. X
  1015. X    OrbitGadgets = gadgets = MakeOrbitGads();
  1016. X
  1017. X    if (gadgets == NULL) {
  1018. X      return( -1 );
  1019. X    }
  1020. X
  1021. X    Window = OpenMyWind(&NewOrbit, screen, gadgets,
  1022. X                         NewOrbit.Width, NewOrbit.Height );
  1023. X
  1024. X    if (Window == NULL) {
  1025. X
  1026. X      DispErrMsg("Can't open picture window",0);
  1027. X      FreeGadgets( OrbitGadgets );
  1028. X      return( -1 );
  1029. X
  1030. X    } else {
  1031. X
  1032. X      OrbitWind = Window;
  1033. X      MoveResize( Window, &OrbitResize );
  1034. X      BorderWindow( Window );
  1035. X    }
  1036. X  }
  1037. X
  1038. X  OrbitOpen = 1;
  1039. X  State = ORBITSTATE;
  1040. X  SetToPointer();
  1041. X  return( 0 );
  1042. X} /* OpenOrbit */
  1043. X
  1044. X/*
  1045. X * Close the Orbit Window
  1046. X */
  1047. XCloseOrbitWind()
  1048. X{
  1049. X  register struct Window    *Window;
  1050. X  register struct NewWindow *NewWindow;
  1051. X
  1052. X  Window = OrbitWind;
  1053. X
  1054. X  if ( Window != NULL) {
  1055. X
  1056. X    NewOrbit.LeftEdge = Window->LeftEdge;
  1057. X    NewOrbit.TopEdge  = Window->TopEdge;
  1058. X    NewOrbit.Width    = Window->Width;
  1059. X    NewOrbit.Height   = Window->Height;
  1060. X
  1061. X    CloseMyWind(Window, OrbitGadgets );
  1062. X
  1063. X    OrbitWind    = NULL;
  1064. X    OrbitGadgets = NULL;
  1065. X  }
  1066. X}
  1067. SHAR_EOF
  1068. echo "extracting orbitint.c"
  1069. sed 's/^X//' << \SHAR_EOF > orbitint.c
  1070. X/*
  1071. X * MandelVroom 2.0
  1072. X *
  1073. X * (c) Copyright 1987,1989  Kevin L. Clague, San Jose, CA
  1074. X *
  1075. X * All rights reserved.
  1076. X *
  1077. X * Permission is hereby granted to distribute this program's source
  1078. X * executable, and documentation for non-comercial purposes, so long as the
  1079. X * copyright notices are not removed from the sources, executable or
  1080. X * documentation.  This program may not be distributed for a profit without
  1081. X * the express written consent of the author Kevin L. Clague.
  1082. X *
  1083. X * This program is not in the public domain.
  1084. X *
  1085. X * Fred Fish is expressly granted permission to distribute this program's
  1086. X * source and executable as part of the "Fred Fish freely redistributable
  1087. X * Amiga software library."
  1088. X *
  1089. X * Permission is expressly granted for this program and it's source to be
  1090. X * distributed as part of the Amicus Amiga software disks, and the
  1091. X * First Amiga User Group's Hot Mix disks.
  1092. X *
  1093. X * contents: this file contains functions to calculate and draw orbits for
  1094. X * fixed point (scaled int) math mode.
  1095. X */
  1096. X
  1097. X#include "mandp.h"
  1098. X
  1099. X#include "parms.h"
  1100. X
  1101. Xstatic double x_scale,  y_scale;
  1102. Xstatic int    x_center, y_center;
  1103. Xstatic int    rightedge,botedge;
  1104. Xstatic struct RastPort *Rp;
  1105. X
  1106. Xextern SHORT MaxOrbit;
  1107. X
  1108. X#define ORBSHIFT 27
  1109. X#define ORBINT(f) ((int)((f)*(double)(1<<ORBSHIFT)))
  1110. X
  1111. XInitIntOrbit()
  1112. X{
  1113. X  register struct Window *Window;
  1114. X  register int    width,  height;
  1115. X
  1116. X  Window = OrbitWind;
  1117. X  Rp = Window->RPort;
  1118. X
  1119. X  width  = (Window->Width-LEFTMARG-RIGHTMARG);
  1120. X  height = (Window->Height-TOPMARG-BOTMARG);
  1121. X
  1122. X  rightedge = width + LEFTMARG - 1;
  1123. X  botedge   = height + TOPMARG - 1;
  1124. X
  1125. X  x_scale = y_scale = (float) height / (2.0 * (double)(1<<ORBSHIFT));
  1126. X
  1127. X  x_center = width/2 + LEFTMARG;
  1128. X  y_center = height/2 + TOPMARG;
  1129. X}
  1130. X
  1131. Xstatic char first_flag;
  1132. X
  1133. XDrawOrbitInt( Pict )
  1134. X  struct Picture *Pict;
  1135. X{
  1136. X  struct IntPotParms Parms;
  1137. X  LONG creal, cimag;
  1138. X  LONG sreal, simag;
  1139. X
  1140. X  InitIntOrbit();
  1141. X
  1142. X  creal = ORBINT( Pict->RealLow + (MouseX-Pict->LeftMarg) * Pict->RealGap );
  1143. X  cimag = ORBINT( Pict->ImagLow + (MouseY-Pict->TopMarg)  * Pict->ImagGap );
  1144. X
  1145. X  sreal = ORBINT( Pict->Real );
  1146. X  simag = ORBINT( Pict->Imag );
  1147. X
  1148. X  if ( Pict->pNode.ln_Type == MANDPICT ) {
  1149. X
  1150. X    Parms.C_Real = creal;
  1151. X    Parms.C_Imag = cimag;
  1152. X
  1153. X    Parms.ScreenReal = sreal;
  1154. X    Parms.ScreenImag = simag;
  1155. X  } else {
  1156. X
  1157. X    Parms.C_Real = sreal;
  1158. X    Parms.C_Imag = simag;
  1159. X
  1160. X    Parms.ScreenReal = creal;
  1161. X    Parms.ScreenImag = cimag;
  1162. X  }
  1163. X
  1164. X  Parms.MaxIteration = MaxOrbit;
  1165. X
  1166. X  /* Clear the window for next display plot */
  1167. X
  1168. X  SetAPen(Rp, 0);
  1169. X  RectFill(Rp, LEFTMARG,TOPMARG, rightedge, botedge);
  1170. X  SetAPen(Rp, HIGHLIGHTPEN);
  1171. X
  1172. X  first_flag = 0;
  1173. X
  1174. X  Orbit3216( &Parms );
  1175. X}
  1176. X
  1177. XPlotIntOrbit( zreal, zimag )
  1178. X  LONG zreal, zimag;
  1179. X{
  1180. X  int x,y;
  1181. X
  1182. X  x = x_center + (int)((double) zreal * x_scale);
  1183. X  y = y_center + (int)((double) zimag * y_scale);
  1184. X
  1185. X  if (x >= LEFTMARG && x <= rightedge &&
  1186. X      y >= TOPMARG  && y <= botedge   &&
  1187. X      first_flag == 1                   ) {
  1188. X
  1189. X    WritePixel( Rp, x, y );
  1190. X  }
  1191. X  first_flag = 1;
  1192. X}
  1193. X
  1194. X/*
  1195. X *  Orbit display for 32 bit math using 16 bit multiplies.
  1196. X *  It is written for the 68000 instruction set.
  1197. X */
  1198. XOrbit3216( Parms )
  1199. X
  1200. X  struct IntPotParms *Parms;
  1201. X{
  1202. X  LONG Height;
  1203. X
  1204. X  register struct IntPotParms *P = Parms;
  1205. X
  1206. X  register LONG cura, curb, cura2, curb2;
  1207. X
  1208. X#asm
  1209. Xheight  equ -4
  1210. XBits2Shift equ  5
  1211. X;
  1212. X;
  1213. X;  d1 - BITS2SHIFT
  1214. X;  d2 - k
  1215. X;  d4 - a
  1216. X;  d5 - b
  1217. X;  d6 - a2
  1218. X;  d7 - b2
  1219. X;
  1220. Xscreenr  equ 0
  1221. Xscreeni  equ 4
  1222. Xcurx     equ 8
  1223. Xcury     equ 12
  1224. Xmaxi     equ 16
  1225. X;
  1226. X   move.l   #Bits2Shift,d1
  1227. X   move.l   screenr(a2),d4
  1228. X   move.l   screeni(a2),d5
  1229. X   move.w   maxi(a2),d2
  1230. X   bra      Fposa2
  1231. X;
  1232. XFKLoop
  1233. X;
  1234. X;  cura = cura2 - curb2 + curx;
  1235. X   exg      d6,d4       ; exchange cura and cura2
  1236. X   sub.l    d7,d4       ; subtract curb
  1237. X   add.l    curx(a2),d4 ; add curx
  1238. X;
  1239. X;  curb = cura * curb >> 12;
  1240. X   move.l   d6,d7      ; get copy of op1 sign bit
  1241. X   bpl      Fpos1       ; get absolute value of op1
  1242. X   neg.l    d6
  1243. XFpos1
  1244. X   eor.l    d5,d7      ; calculate result sign
  1245. X   tst.l    d5         ; get absolute value of op2
  1246. X   bpl      Fpos2
  1247. X   neg.l    d5
  1248. XFpos2
  1249. X   move.l   d6,d0      ; get a copy of op1
  1250. X   swap     d0         ; get high half of op1
  1251. X   move.w   d0,d7      ; save a copy of high half
  1252. X   mulu     d5,d0      ; multiply op2 low by op1 high
  1253. X   clr.w    d0         ;  clear least significant part
  1254. X   swap     d0         ;  put it in it's place
  1255. X   swap     d5         ; get high half of op2
  1256. X   mulu     d5,d6      ; multiply op2 high with op1 low
  1257. X   clr.w    d6         ;  clear least significant part
  1258. X   swap     d6         ;  put it in its place
  1259. X   mulu     d7,d5      ; multiply op2 high by op1 high
  1260. X   add.l    d0,d5      ; add partial results
  1261. X   add.l    d6,d5      ; add partial results
  1262. X   tst.l    d7         ; is the result negative?
  1263. X   bpl      Fpos3
  1264. X   neg.l    d5         ; yes, better negate it.
  1265. XFpos3
  1266. X   asl.l    d1,d5      ; now, rescale it.
  1267. X;
  1268. X;  curb += curb + cury;
  1269. X   add.l    d5,d5      ; double it and add cury
  1270. X   add.l    cury(a2),d5
  1271. XFposa2
  1272. X;
  1273. X;  cura2 = cura * cura;
  1274. X   move.l   d4,d0      ; get absolute value of a in d0
  1275. X   bpl      Fposa
  1276. X   neg.l    d0
  1277. XFposa
  1278. X   move.l   d0,d6      ; copy absolute value into d6
  1279. X   swap     d6         ; get high part in d6
  1280. X   mulu     d6,d0      ; multiply high and low destroying low
  1281. X   clr.w    d0         ; clear the least significant part
  1282. X   swap     d0         ; put most sig. part in low half
  1283. X   mulu     d6,d6      ; multiply high and high destroing high
  1284. X   add.l    d0,d6      ; add in lower half twice
  1285. X   add.l    d0,d6
  1286. X   asl.l    d1,d6      ; get radix point back in correct place
  1287. X   bvs      Fbailout
  1288. X;
  1289. X;  curb2 = curb * curb;
  1290. X   move.l   d5,d0      ; get absolute value of a in d0
  1291. X   bpl      Fposb
  1292. X   neg.l    d0
  1293. XFposb
  1294. X   move.l   d0,d7      ; copy absolute value into d7
  1295. X   swap     d7         ; get high part in d7
  1296. X   mulu     d7,d0      ; multiply high and low destroying low
  1297. X   clr.w    d0         ; clear the least significant part
  1298. X   swap     d0         ; put most sig. part in low half
  1299. X   mulu     d7,d7      ; multiply high and high destroing high
  1300. X   add.l    d0,d7      ; add in lower half twice
  1301. X   add.l    d0,d7
  1302. X   asl.l    d1,d7      ; get radix point back in correct place
  1303. X   bvs      Fbailout
  1304. X;
  1305. X   movem.l  .saveregs,-(sp)
  1306. X;
  1307. X#endasm
  1308. X   PlotIntOrbit(cura,curb);
  1309. X#asm
  1310. X;
  1311. X   movem.l  (sp)+,.saveregs
  1312. X;
  1313. X   move.l   d6,d0      ; if (cura2 + curb2 >= 4) goto bailout;
  1314. X   add.l    d7,d0
  1315. X   bvs      Fbailout
  1316. X;
  1317. X   dbra     d2,FKLoop
  1318. X;  addq     #1,d2
  1319. XFbailout
  1320. X   move.w   maxi(a2),d0
  1321. X   sub.w    d2,d0
  1322. X   sub.w    #1,d0
  1323. X   ext.l    d0
  1324. X#endasm
  1325. X   ;;
  1326. X}
  1327. X
  1328. X#asm
  1329. X.saveregs   reg     d0-d3/a2
  1330. X#endasm
  1331. X
  1332. X
  1333. X
  1334. SHAR_EOF
  1335. echo "extracting packer.c"
  1336. sed 's/^X//' << \SHAR_EOF > packer.c
  1337. X/*----------------------------------------------------------------------*
  1338. X * packer.c Convert data to "cmpByteRun1" run compression.     11/15/85
  1339. X *
  1340. X * By Jerry Morrison and Steve Shaw, Electronic Arts.
  1341. X * This software is in the public domain.
  1342. X *
  1343. X *    control bytes:
  1344. X *     [0..127]   : followed by n+1 bytes of data.
  1345. X *     [-1..-127] : followed by byte to be repeated (-n)+1 times.
  1346. X *     -128       : NOOP.
  1347. X *
  1348. X * This version for the Commodore-Amiga computer.
  1349. X *----------------------------------------------------------------------*/
  1350. X#include "iff/packer.h"
  1351. X
  1352. X#define DUMP    0
  1353. X#define RUN    1
  1354. X
  1355. X#define MinRun 3    
  1356. X#define MaxRun 128
  1357. X#define MaxDat 128
  1358. X
  1359. XLONG putSize;
  1360. X#define GetByte()    (*source++)
  1361. X#define PutByte(c)    { *dest++ = (c);   ++putSize; }
  1362. X
  1363. Xchar buf[256];    /* [TBD] should be 128?  on stack?*/
  1364. X
  1365. XBYTE *PutDump(dest, nn)  BYTE *dest;  int nn; {
  1366. X    int i;
  1367. X
  1368. X    PutByte(nn-1);
  1369. X    for(i = 0;  i < nn;  i++)   PutByte(buf[i]);
  1370. X    return(dest);
  1371. X    }
  1372. X
  1373. XBYTE *PutRun(dest, nn, cc)   BYTE *dest;  int nn, cc; {
  1374. X    PutByte(-(nn-1));
  1375. X    PutByte(cc);
  1376. X    return(dest);
  1377. X    }
  1378. X
  1379. X#define OutDump(nn)   dest = PutDump(dest, nn)
  1380. X#define OutRun(nn,cc) dest = PutRun(dest, nn, cc)
  1381. X
  1382. X/*----------- PackRow --------------------------------------------------*/
  1383. X/* Given POINTERS TO POINTERS, packs one row, updating the source and
  1384. X   destination pointers.  RETURNs count of packed bytes.*/
  1385. XLONG PackRow(pSource, pDest, rowSize)
  1386. X    BYTE **pSource, **pDest;   LONG rowSize; {
  1387. X    BYTE *source, *dest;
  1388. X    char c,lastc = '\0';
  1389. X    BOOL mode = DUMP;
  1390. X    short nbuf = 0;        /* number of chars in buffer */
  1391. X    short rstart = 0;        /* buffer index current run starts */
  1392. X
  1393. X    source = *pSource;
  1394. X    dest = *pDest;
  1395. X    putSize = 0;
  1396. X    buf[0] = lastc = c = GetByte();  /* so have valid lastc */
  1397. X    nbuf = 1;   rowSize--;    /* since one byte eaten.*/
  1398. X
  1399. X
  1400. X    for (;  rowSize;  --rowSize) {
  1401. X    buf[nbuf++] = c = GetByte();
  1402. X    switch (mode) {
  1403. X        case DUMP: 
  1404. X            /* If the buffer is full, write the length byte,
  1405. X               then the data */
  1406. X            if (nbuf>MaxDat) {
  1407. X                OutDump(nbuf-1);  
  1408. X                buf[0] = c; 
  1409. X                nbuf = 1;   rstart = 0; 
  1410. X                break;
  1411. X                }
  1412. X
  1413. X            if (c == lastc) {
  1414. X                if (nbuf-rstart >= MinRun) {
  1415. X                if (rstart > 0) OutDump(rstart);
  1416. X                mode = RUN;
  1417. X                }
  1418. X                else if (rstart == 0)
  1419. X                mode = RUN;    /* no dump in progress,
  1420. X                so can't lose by making these 2 a run.*/
  1421. X                }
  1422. X            else  rstart = nbuf-1;        /* first of run */ 
  1423. X            break;
  1424. X
  1425. X        case RUN: if ( (c != lastc)|| ( nbuf-rstart > MaxRun)) {
  1426. X                /* output run */
  1427. X               OutRun(nbuf-1-rstart,lastc);
  1428. X                buf[0] = c;
  1429. X                nbuf = 1; rstart = 0;
  1430. X                mode = DUMP;
  1431. X                }
  1432. X            break;
  1433. X        }
  1434. X
  1435. X    lastc = c;
  1436. X    }
  1437. X
  1438. X    switch (mode) {
  1439. X    case DUMP: OutDump(nbuf); break;
  1440. X    case RUN: OutRun(nbuf-rstart,lastc); break;
  1441. X    }
  1442. X    *pSource = source;
  1443. X    *pDest = dest;
  1444. X    return(putSize);
  1445. X    }
  1446. X
  1447. SHAR_EOF
  1448. echo "extracting palette.c"
  1449. sed 's/^X//' << \SHAR_EOF > palette.c
  1450. X/*
  1451. X * MandelVroom 2.0
  1452. X *
  1453. X * (c) Copyright 1987,1989  Kevin L. Clague, San Jose, CA
  1454. X *
  1455. X * All rights reserved.
  1456. X *
  1457. X * Permission is hereby granted to distribute this program's source
  1458. X * executable, and documentation for non-comercial purposes, so long as the
  1459. X * copyright notices are not removed from the sources, executable or
  1460. X * documentation.  This program may not be distributed for a profit without
  1461. X * the express written consent of the author Kevin L. Clague.
  1462. X *
  1463. X * This program is not in the public domain.
  1464. X *
  1465. X * Fred Fish is expressly granted permission to distribute this program's
  1466. X * source and executable as part of the "Fred Fish freely redistributable
  1467. X * Amiga software library."
  1468. X *
  1469. X * Permission is expressly granted for this program and it's source to be
  1470. X * distributed as part of the Amicus Amiga software disks, and the
  1471. X * First Amiga User Group's Hot Mix disks.
  1472. X *
  1473. X * contents: this file contains the functions that open, maintain, operate
  1474. X * and close the color palette.
  1475. X */
  1476. X
  1477. X#include "mandp.h"
  1478. X
  1479. X#include <ctype.h>
  1480. X
  1481. X#define PENLEFT 8
  1482. X#define PENTOP  15
  1483. X
  1484. Xextern struct Gadget *ContGadget[], *SelGadget[];
  1485. X
  1486. XUBYTE PaletteOpen;
  1487. X
  1488. X/*
  1489. X * Holder for Allocated color potentiometer gadgets.
  1490. X */
  1491. Xstruct ColorGads {
  1492. X  struct Gadget *RedPot;
  1493. X  struct Gadget *GreenPot;
  1494. X  struct Gadget *BluePot;
  1495. X};
  1496. X
  1497. Xstruct Window          *PalWind;
  1498. Xstruct ColorGads        PalGads;
  1499. X
  1500. XLONG CurPen;
  1501. X
  1502. Xstruct NewWindow NewPal = {
  1503. X   128,0,                    /* start position           */
  1504. X   70,80,                    /* width, height            */
  1505. X   (UBYTE) 0, (UBYTE) -1,   /* detail pen, block pen    */
  1506. X   NULL,                     /* IDCMP flags */
  1507. X                             /* MandWind flags */
  1508. X   WINDOWCLOSE   | WINDOWDRAG | WINDOWDEPTH | NOCAREREFRESH | SMART_REFRESH,
  1509. X   (struct Gadget *) NULL,   /* first gadget             */
  1510. X   (struct Image *) NULL,    /* user checkmark           */
  1511. X   (UBYTE *) "Colors",       /* window title             */
  1512. X   (struct Screen *) NULL,   /* pointer to screen        */
  1513. X   (struct BitMap *) NULL,   /* pointer to superbitmap   */
  1514. X   80,80,80,80,              /* sizing                   */
  1515. X   CUSTOMSCREEN              /* type of screen           */
  1516. X   };
  1517. X
  1518. X/*
  1519. X * Color Palette Commands
  1520. X */
  1521. X
  1522. XCopyRGBCmd(Msg)
  1523. X  struct IntuiMessage *Msg;
  1524. X{
  1525. X  struct Gadget  *gadget;
  1526. X  register LONG rgb, pen;
  1527. X
  1528. X  /* Need contour selection to complete */
  1529. X
  1530. X  gadget = (struct Gadget *) Msg->IAddress;
  1531. X
  1532. X  if (Msg->Class == GADGETDOWN) {
  1533. X
  1534. X    if (gadget->GadgetID == PALCOPY) { /* Copy command gadget */
  1535. X
  1536. X      SetToPointer();
  1537. X      State = COPYRGBSTATE;
  1538. X    } else {
  1539. X
  1540. X      if (GADG_TYPE(gadget->GadgetID) == PALPEN) {
  1541. X
  1542. X        /* Copy the RGBs from CurPen to NewPen */
  1543. X
  1544. X        pen = GADG_NUM(gadget->GadgetID);
  1545. X        rgb = GetRGB4(vp->ColorMap, CurPen);
  1546. X        SetRGB4(vp, pen, rgb >> 8, rgb >> 4, rgb);
  1547. X        SaveRGBs(CurPict);
  1548. X
  1549. X        State = IDLESTATE;
  1550. X      }
  1551. X    }
  1552. X  }
  1553. X}
  1554. X
  1555. XSpreadRGBCmd(Msg)
  1556. X  struct IntuiMessage *Msg;
  1557. X{
  1558. X  struct Gadget *gadget;
  1559. X  register LONG  pen;
  1560. X
  1561. X  /* Need contour selection to complete */
  1562. X
  1563. X  gadget = (struct Gadget *) Msg->IAddress;
  1564. X
  1565. X  if (Msg->Class == GADGETDOWN) {
  1566. X
  1567. X    if (gadget->GadgetID == PALRANGE) { /* Spread command gadget */
  1568. X
  1569. X      SetToPointer();
  1570. X      State = SPREADRGBSTATE;
  1571. X    } else {
  1572. X
  1573. X      if (GADG_TYPE(gadget->GadgetID) == PALPEN) {
  1574. X
  1575. X        /* Spread the RGBs from CurPen to NewPen */
  1576. X
  1577. X        pen = GADG_NUM(gadget->GadgetID);
  1578. X        ColorRange(CurPen, pen);
  1579. X        SaveRGBs(CurPict);
  1580. X
  1581. X        State = IDLESTATE;
  1582. X      }
  1583. X    }
  1584. X  }
  1585. X}
  1586. X
  1587. XExchangeRGBCmd(Msg)
  1588. X  struct IntuiMessage *Msg;
  1589. X{
  1590. X  register LONG rgb, rgb2, pen;
  1591. X  struct Gadget *gadget;
  1592. X
  1593. X  /* Need contour selection to complete */
  1594. X
  1595. X  gadget = (struct Gadget *) Msg->IAddress;
  1596. X
  1597. X  if (Msg->Class == GADGETDOWN) {
  1598. X
  1599. X    if (gadget->GadgetID == PALEXCG) { /* Exchange command gadget */
  1600. X
  1601. X      SetWithPointer();
  1602. X      State = XCHGRGBSTATE;
  1603. X    } else {
  1604. X
  1605. X      if (GADG_TYPE(gadget->GadgetID) == PALPEN) {
  1606. X
  1607. X        /* exchange the RGBs in CurPen and NewPen */
  1608. X
  1609. X        pen = GADG_NUM(gadget->GadgetID);
  1610. X        rgb  = GetRGB4(vp->ColorMap, CurPen);
  1611. X        rgb2 = GetRGB4(vp->ColorMap, pen);
  1612. X        SetRGB4(vp, CurPen, rgb2 >> 8, rgb2 >> 4, rgb2 );
  1613. X        SetRGB4(vp, pen,    rgb  >> 8, rgb  >> 4, rgb  );
  1614. X        SaveRGBs(CurPict);
  1615. X
  1616. X        State = IDLESTATE;
  1617. X      }
  1618. X    }
  1619. X  }
  1620. X}
  1621. X
  1622. XSlideRGBCmd(Msg)
  1623. X  struct IntuiMessage *Msg;
  1624. X{
  1625. X  struct Gadget *gadget;
  1626. X
  1627. X  gadget = (struct Gadget *) Msg->IAddress;
  1628. X
  1629. X  switch( Msg->Class ) {
  1630. X
  1631. X    case GADGETDOWN:                          /* Start RGB slide    */
  1632. X         StartBarDrag();
  1633. X         State = SLIDERGBSTATE;
  1634. X         break;
  1635. X
  1636. X    case MOUSEMOVE:
  1637. X         ModifyColors();                      /* change RGB colors */
  1638. X         break;
  1639. X
  1640. X    case GADGETUP:                            /* Stop the RGB slide */
  1641. X         ModifyColors();
  1642. X         SaveRGBs(CurPict);
  1643. X         State = IDLESTATE;
  1644. X         break;
  1645. X  }
  1646. X}
  1647. X
  1648. XSetCurPen( pen )
  1649. X  int pen;
  1650. X{
  1651. X  BoxPen( CurPen, NORMALPEN );
  1652. X  CurPen = pen;
  1653. X  SetColorProps(pen);
  1654. X  BoxPen( CurPen, MEDIUMPEN );
  1655. X  SaveRGBs( CurPict );
  1656. X}
  1657. X
  1658. X/*
  1659. X * Blend a range of colors between two pens
  1660. X */
  1661. XColorRange(first, last)
  1662. X  LONG first, last;
  1663. X{
  1664. X    LONG i;
  1665. X    register LONG whole, redfraction, greenfraction, bluefraction;
  1666. X    register USHORT rgb;
  1667. X    LONG firstred, firstgreen, firstblue;
  1668. X    LONG lastred, lastgreen, lastblue;
  1669. X    LONG workred, workgreen, workblue;
  1670. X
  1671. X    if (first > last) {
  1672. X        i = first;
  1673. X        first = last;
  1674. X        last = i;
  1675. X     }
  1676. X
  1677. X    /* I need to see a spread of at least two, where there's at least one
  1678. X     * spot between the endpoints, else there's no work to do so I
  1679. X     * might as well just return now.
  1680. X     */
  1681. X    if (first >= last - 1) return;
  1682. X
  1683. X    rgb = GetRGB4(vp->ColorMap, first);
  1684. X    firstred = (rgb >> 8) & 0xF;
  1685. X    firstgreen = (rgb >> 4) & 0xF;
  1686. X    firstblue = (rgb >> 0) & 0xF;
  1687. X
  1688. X    rgb = GetRGB4(vp->ColorMap, last);
  1689. X    lastred = (rgb >> 8) & 0xF;
  1690. X    lastgreen = (rgb >> 4) & 0xF;
  1691. X    lastblue = (rgb >> 0) & 0xF;
  1692. X
  1693. X    whole = (lastred - firstred) << 16;
  1694. X    redfraction = whole / (last - first);
  1695. X    whole = (lastgreen - firstgreen) << 16;
  1696. X    greenfraction = whole / (last - first);
  1697. X    whole = (lastblue - firstblue) << 16;
  1698. X    bluefraction = whole / (last - first);
  1699. X
  1700. X    for (i = first + 1; i < last; i++)
  1701. X        {
  1702. X        lastred = (redfraction * (i - first) + 0x8000) >> 16;
  1703. X        workred = firstred + lastred;
  1704. X        lastgreen = (greenfraction * (i - first) + 0x8000) >> 16;
  1705. X        workgreen = firstgreen + lastgreen;
  1706. X        lastblue = (bluefraction * (i - first) + 0x8000) >> 16;
  1707. X        workblue = firstblue + lastblue;
  1708. X        SetRGB4(vp, i, workred, workgreen, workblue);
  1709. X        }
  1710. X} /* ColorRange */
  1711. X
  1712. X/*
  1713. X * Modify the colors in the current pen
  1714. X */
  1715. XModifyColors( )
  1716. X{
  1717. X  register LONG newred, newgreen, newblue;
  1718. X
  1719. X  newred = ((struct PropInfo *)
  1720. X           PalGads.RedPot->SpecialInfo)->VertPot >> 12;
  1721. X  newgreen = ((struct PropInfo *)
  1722. X           PalGads.GreenPot->SpecialInfo)->VertPot >> 12;
  1723. X  newblue = ((struct PropInfo *)
  1724. X           PalGads.BluePot->SpecialInfo)->VertPot >> 12;
  1725. X
  1726. X  newred   = 0xF ^ newred;
  1727. X  newgreen = 0xF ^ newgreen;
  1728. X  newblue  = 0xF ^ newblue;
  1729. X
  1730. X  PrintRGB( newred, newgreen, newblue );
  1731. X
  1732. X  SetRGB4(vp, CurPen, newred, newgreen, newblue);
  1733. X} /* ModifyColors */
  1734. X
  1735. XPrintRGB( r, g, b )
  1736. X  LONG r,g,b;
  1737. X{
  1738. X  PrintGad( PalGads.RedPot,   r );
  1739. X  PrintGad( PalGads.GreenPot, g );
  1740. X  PrintGad( PalGads.BluePot,  b );
  1741. X}
  1742. X
  1743. XPrintGad( gadget, Color )
  1744. X  register struct Gadget *gadget;
  1745. X  LONG   Color;
  1746. X{
  1747. X  register struct IntuiText *SaveIntui, *IntuiText = gadget->GadgetText;
  1748. X
  1749. X  char d[4];
  1750. X
  1751. X  SaveIntui = IntuiText;
  1752. X
  1753. X  Color &= 0xf;
  1754. X  sprintf( d, "%x", Color );
  1755. X
  1756. X  d[0] = toupper(d[0]);
  1757. X
  1758. X  IntuiText = IntuiText->NextText;
  1759. X
  1760. X  IntuiText->IText[0] = d[0];
  1761. X
  1762. X  IntuiText = IntuiText->NextText;
  1763. X
  1764. X  IntuiText->IText[0] = d[0];
  1765. X
  1766. X  PrintIText( PalWind->RPort, SaveIntui, gadget->LeftEdge, gadget->TopEdge);
  1767. X}
  1768. X
  1769. X/*
  1770. X * Reflect a pen's new color in the proportional gadget
  1771. X */
  1772. XSetColorProps(pen)
  1773. X  LONG pen;
  1774. X{
  1775. X  register LONG rgb, red, green, blue;
  1776. X
  1777. X  if (PalWind == NULL)
  1778. X    return;
  1779. X
  1780. X  pen &= Num_vp_Colors - 1;
  1781. X
  1782. X  rgb = GetRGB4(vp->ColorMap, pen);
  1783. X
  1784. X  red = 0xF - ((rgb >> 8) & 0xF);
  1785. X  green = 0xF - ((rgb >> 4) & 0xF);
  1786. X  blue = 0xF - (rgb & 0xF);
  1787. X
  1788. X  red   |= (red << 4);
  1789. X  red   |= (red << 8);
  1790. X  green |= (green << 4);
  1791. X  green |= (green << 8);
  1792. X  blue  |= (blue <<  4);
  1793. X  blue  |= (blue <<  8);
  1794. X
  1795. X  NewModifyProp(PalGads.RedPot,  PalWind,NULL,FREEVERT|PROPBORDERLESS,
  1796. X             0L,red,0L,0xfffL,1L);
  1797. X  NewModifyProp(PalGads.GreenPot,PalWind,NULL,FREEVERT|PROPBORDERLESS,
  1798. X             0L,green,0L,0xfffL,1L);
  1799. X  NewModifyProp(PalGads.BluePot, PalWind,NULL,FREEVERT|PROPBORDERLESS,
  1800. X             0L,blue,0L,0xfffL,1L);
  1801. X} /* SetColorProps */
  1802. X
  1803. XBoxPen(BoxPen, DrawPen)
  1804. X  LONG BoxPen, DrawPen;
  1805. X{
  1806. X  register LONG  Top, Bot, Left, Right;
  1807. X  register ULONG row, column;
  1808. X
  1809. X#define PALTOP    (PENTOP - 1)
  1810. X#define PALLEFT   (PENLEFT - 1)
  1811. X#define PENWIDTH  (4 << XScale)
  1812. X#define PENHEIGHT (4 << YScale)
  1813. X#define PENXPITCH (6 << XScale)
  1814. X#define PENYPITCH (6 << YScale)
  1815. X
  1816. X  if (PalWind == NULL)
  1817. X    return;
  1818. X
  1819. X  column = BoxPen/8;
  1820. X
  1821. X  row = BoxPen - column*8;
  1822. X
  1823. X  SetAPen(PalWind->RPort, DrawPen);
  1824. X
  1825. X  Left  = PALLEFT + PENXPITCH * column;
  1826. X  Top   = PALTOP  + PENYPITCH * row;
  1827. X  Right = Left    + PENWIDTH  + 2 + XScale;
  1828. X  Bot   = Top     + PENHEIGHT + 2 + YScale;
  1829. X
  1830. X  Move(PalWind->RPort, Left,  Top);
  1831. X  Draw(PalWind->RPort, Right, Top);
  1832. X
  1833. X  if (DrawPen == HIGHLIGHTPEN) SetAPen(PalWind->RPort, SHADOWPEN);
  1834. X
  1835. X  Draw(PalWind->RPort, Right, Bot);
  1836. X  Draw(PalWind->RPort, Left,  Bot);
  1837. X
  1838. X  SetAPen(PalWind->RPort, DrawPen);
  1839. X
  1840. X  Draw(PalWind->RPort, Left,  Top + 1);
  1841. X
  1842. X  if (DrawPen) {
  1843. X    row = GetRGB4(vp->ColorMap, BoxPen & (Num_vp_Colors - 1));
  1844. X    PrintRGB( (long) row >> 8, (long) row >> 4, (long) row );
  1845. X  }
  1846. X}
  1847. X
  1848. Xstatic LONG WindowWidth;
  1849. Xstatic LONG WindowHeight;
  1850. Xstatic LONG BorderLeft;
  1851. X
  1852. Xstatic struct Border *PensBorder;
  1853. X/*
  1854. X * Allocate all the gadgets for the color palette window
  1855. X */
  1856. Xstruct Gadget *MakePalette()
  1857. X{
  1858. X           struct Gadget *FirstGadget;
  1859. X  register struct Gadget *NextGadget;
  1860. X  register LONG i,Left,x,y,c = 0;
  1861. X
  1862. X  struct IntuiText *Text, *NextText;
  1863. X  struct PropInfo  *PropInfo;
  1864. X
  1865. X  LONG fourx = 4 << XScale;
  1866. X  LONG foury = 4 << YScale;
  1867. X
  1868. X  char *str;
  1869. X
  1870. X  Left = PENLEFT;
  1871. X
  1872. X  FirstGadget = NextGadget =
  1873. X    MakeBool( Left, PENTOP, fourx, foury, 0, PALPEN, GADGIMAGE );
  1874. X
  1875. X  if ( FirstGadget == NULL ) goto error;
  1876. X
  1877. X  i = 1 << (screen->BitMap.Depth);
  1878. X
  1879. X  for (x = 0; x < 6*8 && i > 0; x += 6) {
  1880. X    for (y = 0; y < 6*8 && i > 0; y += 6) {
  1881. X      if (c != 0) {
  1882. X
  1883. X        NextGadget->NextGadget =
  1884. X          MakeBool( Left, (y<<YScale)+PENTOP, fourx, foury, c, PALPEN+c,
  1885. X                    GADGIMAGE);
  1886. X
  1887. X        if ((NextGadget = NextGadget->NextGadget) == NULL) goto error;
  1888. X      }
  1889. X      c++;
  1890. X      i--;
  1891. X    }
  1892. X    Left += 6 << XScale;
  1893. X  }
  1894. X  WindowHeight = ((6*8) << YScale) + PENTOP + 6;
  1895. X
  1896. X  c = ((y + 1) << YScale) + 2;
  1897. X
  1898. X  if ( c > WindowHeight ) {
  1899. X    WindowHeight = c + 4;
  1900. X  }
  1901. X
  1902. X  PensBorder = ShadowBorder( BEVELEDUP, 4, 12, Left - 2, c+1);
  1903. X
  1904. X  if (PensBorder == NULL) goto error;
  1905. X
  1906. X  Left += 9;
  1907. X
  1908. X  BorderLeft = Left - 1;
  1909. X
  1910. X  i = -2 * ( XScale ^ 1 );
  1911. X
  1912. X  for (x = y = 0; y < 3; x += 10, y++) {
  1913. X
  1914. X    NextGadget->NextGadget = MakePot( Left + x, 22, fourx,
  1915. X                                      WindowHeight - 35, PALPOT, y);
  1916. X    NextGadget = NextGadget->NextGadget;
  1917. X
  1918. X    if ( NextGadget == NULL ) goto error;
  1919. X
  1920. X    NextGadget->Activation = GADGIMMEDIATE | FOLLOWMOUSE | RELVERIFY;
  1921. X    NextGadget->GadgetText = Text =
  1922. X                           ShadowIntui("0", i, WindowHeight - 32 );
  1923. X    if ( Text == NULL ) goto error;
  1924. X
  1925. X    PropInfo = (struct PropInfo *) NextGadget->SpecialInfo;
  1926. X    PropInfo->VertBody  = 0xfff;
  1927. X
  1928. X    switch (y) {
  1929. X      case 0:  PalGads.RedPot = NextGadget;
  1930. X               str = "R";
  1931. X               break;
  1932. X
  1933. X      case 1:  PalGads.GreenPot = NextGadget;
  1934. X               str = "G";
  1935. X               break;
  1936. X
  1937. X      case 2:  PalGads.BluePot = NextGadget;
  1938. X               str = "B";
  1939. X               break;
  1940. X    }
  1941. X    NextText = Text;
  1942. X
  1943. X    while ( NextText->NextText ) {
  1944. X      NextText = NextText->NextText;
  1945. X    }
  1946. X
  1947. X    NextText->NextText = ShadowIntui( str, i, -11 );
  1948. X
  1949. X    if ( NextText->NextText == NULL ) goto error;
  1950. X  }
  1951. X  Left += 32;
  1952. X
  1953. X  for (c = 0, x = 0; x < 17*3; x += 17) {
  1954. X
  1955. X    NextGadget->NextGadget =
  1956. X      MakeBool( Left, x + 11, 54, 13, 1, PALCNTL+c, NULL);
  1957. X
  1958. X    NextGadget = NextGadget->NextGadget;
  1959. X
  1960. X    if ( NextGadget == NULL) goto error;
  1961. X
  1962. X    switch (c) {
  1963. X      case 0:  NextGadget->GadgetText =
  1964. X                  ShadowIntui("Copy", 12,3);
  1965. X               break;
  1966. X
  1967. X      case 1:  NextGadget->GadgetText =
  1968. X                  ShadowIntui("Spread",4,3);
  1969. X               break;
  1970. X
  1971. X      case 2:  NextGadget->GadgetText =
  1972. X                  ShadowIntui("Exchg", 8,3);
  1973. X               break;
  1974. X    }
  1975. X    c++;
  1976. X  }
  1977. X  WindowWidth = Left + 59;
  1978. X
  1979. X  return(FirstGadget);
  1980. X
  1981. Xerror:
  1982. X  FreeBorder( PensBorder );
  1983. X  FreeGadgets( FirstGadget );
  1984. X  return( NULL );
  1985. X} /* MakePalette */
  1986. X
  1987. Xstatic struct Gadget *PalGadgets;
  1988. X
  1989. X/*
  1990. X * Open the Palette window
  1991. X */
  1992. XOpenPalWind()
  1993. X{
  1994. X  struct Window *OpenMyWind();
  1995. X
  1996. X  register struct Gadget *gadget;
  1997. X  register struct RastPort *Rp;
  1998. X  LONG fourx = 4 << XScale;
  1999. X
  2000. X  if (CurPict == NULL)
  2001. X    return;
  2002. X
  2003. X  if ( PalWind == NULL ) {
  2004. X
  2005. X    gadget = MakePalette();
  2006. X
  2007. X    if ( gadget == NULL ) {
  2008. X      DispErrMsg("Couldn't get palette gadgets", 0 );
  2009. X      return;
  2010. X    }
  2011. X
  2012. X    PalWind = OpenMyWind( &NewPal, screen, NULL, WindowWidth, WindowHeight);
  2013. X
  2014. X    if ( PalWind != NULL ) {
  2015. X
  2016. X      ModifyIDCMP( PalWind,  (long)
  2017. X                   PalWind->IDCMPFlags | MOUSEBUTTONS | MOUSEMOVE );
  2018. X
  2019. X      Rp = PalWind->RPort;
  2020. X
  2021. X      SetAPen( Rp, NORMALPEN );
  2022. X      RectFill( Rp, LEFTMARG, TOPMARG,
  2023. X                WindowWidth,WindowHeight);
  2024. X
  2025. X      BorderWindow( PalWind );
  2026. X
  2027. X      PalGadgets = gadget;
  2028. X
  2029. X      AddGList( PalWind, gadget, -1, -1);
  2030. X
  2031. X      RefreshGadgets( gadget, PalWind, NULL );
  2032. X
  2033. X      DrawBorder( Rp, PensBorder, 0L, 0L );
  2034. X      FreeBorder( PensBorder );
  2035. X
  2036. X      CurPen &= Num_vp_Colors - 1;
  2037. X
  2038. X      BoxPen( CurPen, MEDIUMPEN );
  2039. X      SetColorProps( CurPen );
  2040. X    }
  2041. X  } else {
  2042. X    WindowToFront( PalWind );
  2043. X  }
  2044. X  PaletteOpen = 1;
  2045. X} /* OpenPalWind */
  2046. X
  2047. X/*
  2048. X * Close the Palette window
  2049. X */
  2050. XClosePalWind()
  2051. X{
  2052. X  if (PalWind != NULL) {
  2053. X
  2054. X    NewPal.LeftEdge = PalWind->LeftEdge;
  2055. X    NewPal.TopEdge  = PalWind->TopEdge;
  2056. X
  2057. X    CloseMyWind(PalWind,PalGadgets);
  2058. X    PalGadgets = NULL;
  2059. X  }
  2060. X  PalWind = NULL;
  2061. X} /* ClosePalWind */
  2062. X
  2063. SHAR_EOF
  2064. echo "End of archive 7 (of 9)"
  2065. # if you want to concatenate archives, remove anything after this line
  2066. exit
  2067.